package com.itcast.mallweb.mapper;

import com.itcast.admin.dto.RiderDTO;
import com.itcast.admin.entity.Rider;
import com.itcast.applet.entity.RiderTask;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface RiderMapper {

    //新增骑手
    @Insert("insert into rider(name, account, password, phone, avatar, sex, lat, ing, status)" +
            "values (#{name},#{account},#{password},#{phone},#{avatar},#{sex},#{lat},#{ing},#{status})")
    void addRider(Rider rider);

    //查询单个骑手
    @Select("select * from rider where id = #{id}")
    Rider getById(Long id);

    //查询全部骑手
    @Select("select * from rider")
    List<Rider> getRiderList();

    //批量删除骑手
    void deteleRider(List<Long> ids);

    //创建骑手任务表
    @Insert("insert into rider_task(rider_id, shop_id, order_id, address_id, create_time) values (#{riderId},#{shopId},#{orderId},#{addressId},#{createTime})")
    void insetTask(RiderTask riderTask);

    //查询单个骑手
    @Select("select id, name, account, password, phone, avatar, sex, lat, ing, status from rider where id = #{id}")
    com.itcast.applet.entity.Rider queryGetById(Long id);

    //修改骑手
    void riderAmend(com.itcast.applet.entity.Rider rider);
}
